⚙️ Functions Action Configuration
The Functions action lets you add and run your own inline JavaScript or TypeScript code snippets within your Pageflows, providing powerful customization and logic capabilities.
Features:
- Write custom code to manipulate data, perform calculations, or apply complex logic.
- Access Pageflows variables and inputs within your code.
- Return values that can be used by subsequent Pageflows actions.
- Use TypeScript syntax for type safety and better development experience.
Usage:
- Select the Functions action from the Common tab in the Actions panel.
- Enter or paste your JavaScript/TypeScript code in the editor.
- The function will be executed when the Pageflows reaches this action.
- Use the returned output in downstream nodes or conditional logic.
Example:
function calculateDiscount(price, discountRate) {
const discount = (price * discountRate) / 100;
const finalPrice = price - discount;
return { discountAmount: discount, finalPrice: finalPrice };
}
Use Cases:
- Perform custom data transformations before saving to the database.
- Implement business logic not available in standard Pageflows components.
- Validate or sanitize inputs dynamically.
- Integrate with external APIs by making custom HTTP calls within the function.